/**
 * https://leetcode-cn.com/problems/palindrome-number/
 * 判断是不是回文数字
 * @param x 
 */
const isPalindrome = (x: number): boolean => {
    let y = x,
        reverseX = 0

    // 翻转数字
    while (y !== 0) {
        // 获得个位数
        const n = y % 10;

        // 除于10
        y = ~~(y / 10)
        reverseX = (reverseX * 10) + n
    }

    return x === reverseX
};



const isPalindrome2 = (x: number): boolean => {
    let str = x.toString();

    const len = str.length;

    // 只有一个字符串或者为空
    if (len <= 1) return true;

    let s = 0,
        e = len - 1;

    // 从两头比较
    while (s < e) {
        if (str[s] !== str[e]) return false
        s++;
        e--;
    }

    return true;
};



export { }